package com.zhangsun.springActiveMq.producer;

import com.zhangsun.springActiveMq.common.ActiveMqConstant;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Destination;

@Component
public class TopicProducer {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    public void sendTopic(String msg) {
        Destination destination = new ActiveMQTopic(ActiveMqConstant.TOPIC_HELLO_1);
        jmsMessagingTemplate.convertAndSend(destination, msg);
    }

}
